// 
//  TabHeader.cs
//  
//  Author:
//       Nikita Tsukanov <keks9n@gmail.com>
// 
//  Copyright (c) 2011 Nikita Tsukanov
// 
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
// 
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// 



using System;
using Gtk;
namespace SkypeTab
{
	public class TabHeader:Gtk.HBox
	{
		
		private Label Label=new Label();
		public Label MenuLabel{get; private set;}
		private Button CloseButton=new Button();
		private Image Image=new Image();
		public object Tag;
		System.Reflection.Assembly ass=System.Reflection.Assembly.GetExecutingAssembly();
		string m_Text="";
		public event EventHandler CloseRequest;
		public TabHeader (string Caption)
		{
			MenuLabel=new Label();
			CanFocus=false;
			Label.CanFocus=false;
			CloseButton.CanFocus=false;
			Add(Image);
			Add(Label);
			Add (CloseButton);
			CloseButton.Image=new Image();
			
			((Image)CloseButton.Image).Pixbuf = new Gdk.Pixbuf (ass, "SkypeTab.img.close_button.png");
			Image.Pixbuf= new Gdk.Pixbuf (ass, "SkypeTab.img.icon_mod.png");
			
			CloseButton.Clicked+= delegate {
				if(CloseRequest!=null)
					CloseRequest(this,null);
			};
			
			Label.Show();
			CloseButton.Show();
			Text=Caption;
			
		}
		public string Text
		{
			get
			{
				
				return m_Text;
			}
			set
			{
				string tmp=value;
				if(tmp==null)
					tmp="<unk>";
				MenuLabel.Text=tmp;
				m_Text=tmp;
				if(tmp.StartsWith("*"))
				   tmp=tmp.Substring(1);
				if(tmp.Length>15)
					tmp=tmp.Substring(0,13)+"...";
				Label.Text=tmp;
			}
		}
		public bool HasCloseButton
		{
			get
			{
				return CloseButton.Visible;
			}
			set
			{
				CloseButton.Visible=value;
			}
		}
		public bool Notify
		{
			get
			{
				return Image.Visible;
			}
			set
			{
				Image.Visible=value;
			}
		}
		
	}
}

